﻿using System;
using System.Collections.Generic;
using Microsoft.VisualStudio.TestTools.UnitTesting;
using Lion.WeiXin.Controllers;
using Lion.WeiXin.Core.Models;
namespace Lion.WeiXin.Tests.Controller
{
    [TestClass]
    public class CMSMenuTest
    {
        [TestMethod]
        public void GetNewCodeTest_the_first_of_one_layer()
        {
            CmsMenuController cms = new CmsMenuController();
            List<CmsMenuModel> list = new List<CmsMenuModel>();
            string actual= cms.GetNewCode("000", list);
            Assert.AreEqual("100", actual);
        }

        [TestMethod]
        public void GetNewCodeTest_the_next_of_one_layer()
        {
            CmsMenuController cms = new CmsMenuController();
            List<CmsMenuModel> list = new List<CmsMenuModel>();
            list.Add(new CmsMenuModel() { Code = "100" });
            list.Add(new CmsMenuModel() { Code = "101" });
            list.Add(new CmsMenuModel() { Code = "102" });
            string actual = cms.GetNewCode("000", list);
            Assert.AreEqual("103", actual);
        }

        [TestMethod]
        public void GetNewCodeTest_the_first_of_Two_layer()
        {
            CmsMenuController cms = new CmsMenuController();
            List<CmsMenuModel> list = new List<CmsMenuModel>();
            list.Add(new CmsMenuModel() { Code = "100" });
            list.Add(new CmsMenuModel() { Code = "101" });
            list.Add(new CmsMenuModel() { Code = "102" });
            string actual = cms.GetNewCode("100", list);
            Assert.AreEqual("100001", actual);
        }

        [TestMethod]
        public void GetNewCodeTest_the_Next_of_Two_layer()
        {
            CmsMenuController cms = new CmsMenuController();
            List<CmsMenuModel> list = new List<CmsMenuModel>();
            list.Add(new CmsMenuModel() { Code = "100" });
            list.Add(new CmsMenuModel() { Code = "101" });
            list.Add(new CmsMenuModel() { Code = "102" });
            list.Add(new CmsMenuModel() { Code = "102001" });
            list.Add(new CmsMenuModel() { Code = "102002" });
            string actual = cms.GetNewCode("102", list);
            Assert.AreEqual("102003", actual);
        }


    }
}
